package com.glsc.ngateway.common.base.repo.mysql.gateway.platform.it;

import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it.ItDomainOffice;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface ItOfficeDomainRepo extends JpaRepository<ItDomainOffice, Integer> {

    @Query("select a from ItDomainOffice a where isDelete = 0" +
            "and ((:key is null or FQDN like CONCAT('%',:key,'%')) " +
            "or (:key is null or environment like  CONCAT('%',:key,'%')) " +
            "or (:key is null or useTo like CONCAT('%',:key,'%')) " +
            "or (:key is null or administratorName like CONCAT('%',:key,'%')) " +
            "or (:key is null or oaFlowNum like CONCAT('%',:key,'%')) " +
            "or (:key is null or recode like  CONCAT('%',:key,'%'))) ")
    Page<ItDomainOffice> searchByKey(Pageable pageable, String key);

}
